package edu.gdkm.demo;

//创建一个Teacher类，
// 包含的属性有“教工号”、 “姓名”、 “性别”、 “基本工资”和“奖金”；
// 包含方法:１)打印基本信息。2)计算“基本工资”和“奖金”的和。
public class Teacher {     //公共类类名必须和文件名完全一致！
    //一般情况下，所有的类属性，都使用private进行保护（封装），对属性值的使用，可以通过setter赋值，通过getter取值
    private String teacherId;
    private String name;
    private String sex;
    private double salary;
    private double wage;
    private double payout; //每月支出
    public void print() {
        System.out.println( "edu.gdkm.demo.Teacher{" +
                "teacherId='" + teacherId + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", salary=" + salary +
                ", wage=" + wage +
                '}');
    }

    public double total(){
        double totalIncome= this.salary+this.wage;  //totalIncome 属于是局部变量
        return totalIncome;
    }
    //输出每月的工资结余
    public double balance(double payout){
        //可以通过this关键字，调用类属性和方法，特别是存在同名局部变量时
       return this.total()-this.payout;
    }


    public double getPayout() {
        return payout;
    }

    public void setPayout(double payout) {
        this.payout = payout;
    }

    //构造方法的重构
    public Teacher() {

    }
    public Teacher(String teacherId, String name, String sex, double salary, double wage) {
        this.teacherId = teacherId;
        this.name = name;
        this.sex = sex;
        this.salary = salary;
        this.wage = wage;
    }

    public Teacher(String teacherId, String name, String sex) {
        this.teacherId = teacherId;
        this.name = name;
        this.sex = sex;
    }

    public String getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        if(salary<0){
            this.salary=0;
        }else{
            this.salary = salary;
        }

    }

    public double getWage() {
        return wage;
    }

    public void setWage(double wage) {
        this.wage = wage;
    }
}
